home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 06 General Architectures / 06 Rabin / debuglog.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-12-10  |  1.4 KB  |  65 lines

  1. /* Copyright (C) Steve Rabin, 2001. 
  2.  * All rights reserved worldwide.
  3.  *
  4.  * This software is provided "as is" without express or implied
  5.  * warranties. You may freely copy and compile this source into
  6.  * applications you distribute provided that the copyright text
  7.  * below is included in the resulting source code, for example:
  8.  * "Portions Copyright (C) Steve Rabin, 2001"
  9.  */
  10.  
  11. #include "debuglog.h"
  12. #include "time.h"
  13.  
  14.  
  15. #define MAX_DEBUG_LOG_SIZE 100
  16.  
  17.  
  18. LogEntry::LogEntry( void )
  19. {
  20.     m_owner = INVALID_OBJECT_ID;
  21.     m_handled = false;
  22.  
  23.     m_timestamp = -1.0f;
  24.     strcpy( m_statename, "" );
  25.     strcpy( m_eventmsgname, "" );
  26.     m_receiver = INVALID_OBJECT_ID;
  27.     m_sender = INVALID_OBJECT_ID;
  28.     
  29. }
  30.  
  31.  
  32. DebugLog::DebugLog( void )
  33. {
  34.  
  35. }
  36.  
  37.  
  38. DebugLog::~DebugLog( void )
  39. {
  40.  
  41. }
  42.  
  43.  
  44. void DebugLog::LogStateMachineEvent( objectID id, MSG_Object * msg, char* statename, char* eventmsgname, bool handled )
  45. {
  46.     LogEntry * entry = new LogEntry();
  47.  
  48.     entry->m_owner = id;
  49.     entry->m_handled = handled;
  50.     entry->m_timestamp = g_time.GetCurTime();
  51.     strcpy( entry->m_statename, statename );
  52.     strcpy( entry->m_eventmsgname, eventmsgname );
  53.  
  54.     if( msg ) {
  55.         entry->m_receiver = msg->GetReceiver();
  56.         entry->m_sender = msg->GetSender();
  57.     }
  58.  
  59.     m_log.push_back( entry );
  60.     if( m_log.size() > MAX_DEBUG_LOG_SIZE ) {
  61.         delete( m_log.front() );
  62.         m_log.erase( m_log.begin() );
  63.     }
  64. }
  65.